export default {
  name: "dimission",
  components: {
    resumeDetail: () => import("../../../component/resumeDetail/index.vue"),
    // companyDetail: () => import("../../socical/socialCheck/check.vue")
    companyDetail: () => import("../../socical/socialCheck/check.vue")
  },
  props:['totalNum'],
  data() {
    return {
      tabs: [{
          label: "待处理",
          status: "1"
        },
        {
          label: "已处理",
          status: "2"
        },
      ],
      tableData: [],
      form: {
        companyid: "",
        type: "1",
        starttime: "",
        endtime: "",
        pagenum: 1,
        pagesize: 10
      },
      total: 0,
      dialogVisible: false,
      dialogVisible1: false,
      dialogVisible2: false,
      dialogVisible3: false,
      userid: "",
      nickName: "",
      companyid: "",
      companyname: "",
      params: {
        employeeid: "",
        status: '21',
        note: ""
      },
      abnormalDetail: {}
    }
  },
  created() {
    this.getTableData();
    this.btnAuthority = this.GLOBAL.powerAllBtn.yccl;
  },
  methods: {
    // 时间比较
    compareDate() {
      let starttime = Date.parse(this.form.starttime);
      let endtime = Date.parse(this.form.endtime);
      if (starttime > endtime) {
        this.$message({
          message: '开始时间不能大于结束时间',
          type: 'error'
        });
        return false;
      } else {
        return true;
      }
    },
    clickTab(item) {
      this.form.type = item.status;
      this.form.starttime = "",
      this.form.endtime = "",
      this.form.pagenum = 1,
      this.form.pagesize = 10,
      this.getTableData();
    },
    getTableData() {
      if (!this.compareDate()) {
        return
      } else {
        this.loading = true;
        this.$axios.post("/app/v1/platform/abnormal/employeeList", this.form).then(res => {
          this.loading = false;
          if (res.data.code === 1) {
            this.tableData = res.data.data.list;
            this.total = +res.data.data.totalnum;
			if(this.form.type == 1){this.$emit('update:totalNum',res.data.data.totalnum)};
          } else {
            this.$message({
              message: res.data.message,
              type: "error"
            })
          }
        })
      }
    },
    query() {
      this.form.pagenum = 1;
      this.getTableData();
    },
    // 查看会员详情
    handleClickNickName(row) {
      this.userid = row.userid;
      this.nickName = row.name;
      this.dialogVisible1 = true;
    },
    // 查看公司详情
    handleClickCompanyName(row) {
      this.companyid = row.companyid;
      this.companyname = row.companyname;
      this.dialogVisible2 = true;
    },
    // 显示处理异常对话框
    handleAabnormal(row) {
      this.params.employeeid = row.employeeid;
      this.dialogVisible = true;
    },
    handleReport(row) {
      let params = {
        isShow: true,
        id: row.employeeid,
        reporttype: '9'
      }
      this.$emit('getReportDialogVisible', params);
    },
    // 查看异常详情
    handleClickDetails(row) {
      this.abnormalDetail = row;
      this.dialogVisible3 = true;
    },
    // 处理异常
    submit() {
      this.$confirm('此操作将处理该异常, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.post("/app/v1/platform/abnormal/employeeResult", this.params).then(res => {
          if (res.data.message === 'success.') {
            this.$message({
              message: "处理成功!",
              type: "success"
            });
          } else {
            this.$message({
              message: res.data.message,
              type: "error"
            });
          }
          this.dialogVisible = false;
          this.getTableData();
        })
      }).catch(() => {
        // console.log('已取消删除');
      });
    },
    closeDialog() {
      this.abnormaldetail = {};
      this.params.employeeid = "";
      this.params.status = "21";
      this.params.note = "";
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pagenum = val;
      this.getTableData();
    },
    handleSizeChange(val) {
      this.form.pagesize = val;
      this.getTableData();
    },
  }
}